export const validateAdminData = (adminData) => {
  // 用户名验证
  if (!adminData.adminName || adminData.adminName.length < 2) {
    return {
      isValid: false,
      message: "用户名不能少于2个字符",
    };
  }

  // 邮箱验证
  if (
    adminData.adminEmail &&
    !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(adminData.adminEmail)
  ) {
    return {
      isValid: false,
      message: "邮箱格式不正确",
    };
  }

  // 手机号验证
  if (adminData.adminPhone && !/^1[3-9]\d{9}$/.test(adminData.adminPhone)) {
    return {
      isValid: false,
      message: "手机号格式不正确",
    };
  }

  return { isValid: true };
};

export const validateUserData = (userData) => {
  // 用户名验证
  if (!userData.nickName || userData.nickName.length < 2) {
    return {
      isValid: false,
      message: "昵称不能少于2个字符",
    };
  }

  // 邮箱验证
  if (
    userData.userEmail &&
    !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(userData.userEmail)
  ) {
    return {
      isValid: false,
      message: "邮箱格式不正确",
    };
  }

  // 手机号验证
  if (userData.userPhone && !/^1[3-9]\d{9}$/.test(userData.userPhone)) {
    return {
      isValid: false,
      message: "手机号格式不正确",
    };
  }

  return { isValid: true };
};
